import CryptoJS from 'crypto-js'

export function aesEncrypt(content, key) {
  var parsedKey = CryptoJS.enc.Utf8.parse(key)
  var parsedContent = CryptoJS.enc.Utf8.parse(content)
  var encrypted = CryptoJS.AES.encrypt(parsedContent, parsedKey, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })

  return encrypted.ciphertext.toString()
}

export function aesDecrypt(content, key) {
  var parsedKey = CryptoJS.enc.Utf8.parse(key)
  var decrypt = CryptoJS.AES.decrypt(content, parsedKey, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })

  return CryptoJS.enc.Utf8.stringify(decrypt).toString()
}
